'RKD nmspc: 20120610 :: Imports EntertainmentManager
Imports BusinessLogicLayer
Imports BusinessLogicLayer.BLMain
Imports UniversalLayer.ULMain

''' <summary>
''' NO COMMENTS
''' </summary>
''' <remarks></remarks>
Public Class DLConnector

    Private Enum eRunType
        Final = 0
        Debug = 1
    End Enum

    'Dim _BLMain As BLMain
    Const iRunType As eRunType = eRunType.Debug

#Region "DB Connector"

    ''' <summary>
    ''' Opens a SQL connection to database
    ''' </summary>
    ''' <param name="con">SQL connection to be opened</param>
    ''' <param name="strConnection">SQL Connection String</param>
    ''' <remarks></remarks>
    Public Sub CreateConnection(ByRef con As SqlClient.SqlConnection, ByVal sMSG As String, Optional ByRef strConnection As String = "")

        Try
            If IsEmpty(strConnection) Then
                'If iRunType = eRunType.Final Then strConnection = "Data Source=MUM-PC\BETA;Initial Catalog=MovieMgr;Integrated Security=True" _
                'Else If iRunType = eRunType.Debug Then strConnection = "Data Source=MUM-PC\BETA;Initial Catalog=MovieMgrDemo;Integrated Security=True"
                'RKD : 20120610 :: strConnection = frmEntertainmentManager.sConnectionString
            End If

            con = New SqlClient.SqlConnection(strConnection)
            'MsgBox(sMSG & vbCrLf & CStr(con.ConnectionTimeout), MsgBoxStyle.Information, sMSG)
            con.Open()

        Finally

        End Try
    End Sub

    ''' <summary>
    ''' Closes a SQL connection
    ''' </summary>
    ''' <param name="con">SQL connection to be closed</param>
    ''' <remarks></remarks>
    Public Shared Sub CloseConnection(ByRef con As SqlClient.SqlConnection)
        Try
            con.Close() 'Exception will be thrown if Connection is not opened
        Catch ex As Exception
            'Do Nothing
        End Try
    End Sub

#End Region

End Class
